#include<bits/stdc++.h>

using namespace std;

int main() {
    //freopen("E.in","r",stdin);
    int n, m, x, y;
    int fx[][2] = {0, 1, 0, -1, 1, 0, -1, 0,1,1,1,-1,-1,1,-1,-1};//四连通
    while (cin >> n >> m >> x >> y) {
        vector<vector<int>> v(n, vector<int>(m, 0));
        vector<vector<int>> book(n, vector<int>(m, 0));
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                cin >> v[i][j];
            }
        }
        x--;
        y--;
        queue<pair<int, int>> q;
        q.push(make_pair(x, y));
        book[x][y] = 1;
        int cnt = 0;
        while (!q.empty()) {
            auto head = q.front();
            int hx = head.first;
            int hy = head.second;
            q.pop();
            ++cnt;
            for (int i = 0; i < 4; i++) {
                int nx = hx + fx[i][0];
                int ny = hy + fx[i][1];
                if (nx < 0 || nx >= n || ny < 0 || ny >= m || v[nx][ny] == 0 || book[nx][ny] == 1)continue;
                q.push(make_pair(nx, ny));
                book[nx][ny] = 1;
            }
        }
        cout << cnt << endl;

    }

    return 0;
}